<template>
  <div class="shop">
    <div class="header">
      <span class="icon-back">
       
      </span>
      <span class="title">商家登录</span>
    </div>
    <div class="header-a"></div>
    <div class="body-top">
      <!-- <span class="icon-pic">
        <img :src="images2" class="images2">
      </span> -->
      <span class="companyname">{{shopWorkerName}}</span>
    </div>
    <div class="bigbox">
      <div class="boxleft" @click="wxshao">
        <div>
          <img :src="images14" class="images14">
        </div>
        <div class="text">扫码核销</div>
      </div>
      <div class="boxright" @click="gowriteoff">
        <div>
          <img :src="images15" class="images15">
        </div>
        <div class="text">提货详情</div>
      </div>
    </div>
       <!-- <mt-popup v-model="popupVisible3" position="right" class="mint-popup-3" :modal="false">
      <div @click.native="popupVisible3 = false" size="large" type="primary">关闭 popup</div>
    </mt-popup> -->
    <div class="bottom">
      <div class="btoleft" @click="go">首页</div>
      <div class="btnright" @click="goto">个人中心</div>
    </div>
  </div>
</template>

<script>
import wx from "weixin-js-sdk";

import pic14 from "../../../icons/shaoma.png";
import pic15 from "../../../icons/hexiao.png";
import * as api from "../../../request/api.js";
export default {
  name: "shop",
  data() {
    return {

      images14: pic14,
      images15: pic15,
      shopWorkerName:'',
        popupVisible3: false,
      pickUpToken:''
    };
  },
  created(){
     this.shopWorkerName=this.$route.query.shopWorkerName
   console.log(location.href)
  },
  methods: {
    go() {
      this.$router.push({ path: "./home" });
    },
    goto() {
      this.$router.push({ path: "./man" });
    },
    gowriteoff() {
      this.$router.push({path:'./writeoff'})
    },
    wxshao() {
      const that=this
      that.$http({
        method: "post",
        url: api.JSSDKSGNATURE,
        data: {
          url:(window.location.href).split('#')[0]
        }
      }).then(resp => {
        console.log(resp)
        // 这里【url参数一定是去参的本网址】
        // $.get((url = api.huaxiahong.net), function(data) {
        //   var jsondata = $.parseJSON(data);
        //   alert(jsondata);
        wx.config({
          // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
          debug: false,
          // 必填，公众号的唯一标识
          appId: resp.data.data.appId,
          // 必填，生成签名的时间戳
          timestamp: resp.data.data.timestamp,
          // 必填，生成签名的随机串
          nonceStr: resp.data.data.nonceStr,
          // 必填，签名
          signature: resp.data.data.signature,
          // 必填，需要使用的JS接口列表，所有JS接口列表
          jsApiList: ["checkJsApi", "scanQRCode"]
        });
    
        wx.error(function(res) {
          alert("出错了：" + res.errMsg); //这个地方的好处就是wx.config配置错误，会弹出窗口哪里错误，然后根据微信文档查询即可。
        });
        // const that=this
        wx.ready(function() {
          wx.checkJsApi({
            jsApiList: ["scanQRCode"],
            success: function(res) {
              // alter(res)
            }
          });
      
          wx.scanQRCode({
            needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
            scanType: ["qrCode"], // 可以指定扫二维码还是一维码，默认二者都有
            success: function(res) {
              var pickUpToken = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
              sessionStorage.setItem('pickUpToken',pickUpToken)
              alert("扫描结果：" + that.pickUpToken);
              // this.popupVisible3=true
              // window.location.href="https://api.huaxiahong.net/index.html#/Writeoff"
              that.$router.push({path:"./writeoff",
              query:{
                pickUpToken:res.resultStr
              }});
              
 //因为我这边是扫描后有个链接，然后跳转到该页面
            }
          });
        });
      })
      .catch(resp=>{
       alert(resp)
      })
    }
  }
};
</script>

<style lang="less" scoped>
@import "../../../less/Shop.less";
</style>
